<%@ page import="utils.Book" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="utils.Book" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统管理</title>
    <script src="../bootstrap/js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script>
        function del(){
            var res = confirm('确认要删除吗？');
            if(res == true)
            {
               return true;
            }else{
                return false;
            }
        }
    </script>
</head>
<body>
<div style="height:75px;line-height:75px;font-size:25px;vertical-align: middle;text-align: center" class="bg-primary">柚子书屋系统管理</div>

<div class="row" style="padding:10px 10px">

    <!-- 左导航栏 -->
    <%@include file="../nav.jsp" %>

    <div class="col-md-10" style="padding-top:10px">

        <!-- 查询块 -->
        <div class="search" >
            <form class="form-inline" name="myForm" action="/BookServlet?method=searchBy" method="post">
                <input type="text" class="form-control" name="find" value=""/>
                <input type="submit" class="btn btn-primary" value="查   询" />&nbsp;&nbsp;
                <input type="button" class="btn btn-danger" value="增   加" onclick="javascript:window.location='/book/add.jsp'"/>
                <a href="/BookServlet?method=discount" class="btn btn-danger">一键打折</a>
            </form>
        </div>
        <!-- 图书信息显示-->
        <div style="padding-top:10px;">
            <table class="table table-bordered table-hover" style="text-align:center;">
                <tr>
                    <th>图书ID</th>
                    <th>名称</th>
                    <th>作者</th>
                    <th>出版社</th>
                    <th>价格</th>
                    <th>图片</th>
                    <th>折扣</th>
                    <th colspan=2>操作</th>
                </tr>
                <%
                    ArrayList<Book> list=(ArrayList<Book>)request.getAttribute("books");
                    if(list!=null && list.size()>0)
                    {
                        for(int i=0;i<list.size();i++)
                        {
                %>
                <th class="id"><%=list.get(i).getBook_id()%></th>
                <th><%=list.get(i).getName()%></th>
                <th><%=list.get(i).getAuthor()%></th>
                <th><%=list.get(i).getPublisher()%></th>
                <th ><%=list.get(i).getPrice()%></th>
                <th><%=list.get(i).getUrl()%></th>
                <th><%=list.get(i).getDiscount()%></th>
                <th><a href="/BookServlet?method=searchById&id=<%=list.get(i).getBook_id()%>">修改</a></th>
                <th><a onclick="return del()" href="/BookServlet?method=delete&bookid=<%=list.get(i).getBook_id()%>">删除</a></th>
                </tr>
                <%
                        }
                    }
                %>
            </table>
        </div>
    </div>
</div>
</body>
</html>